home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 5 / BBS in a Box -Volume V (BBS in a Box) (April 1992).iso / Files / Prog / T / TCL⁄C 1.1.2 Update.cpt / THINK C 5.0 Folder / THINK Class Library 1.1 / Table classes / CTable.h / CTable.h
Encoding:
C/C++ Source or Header  |  1991-09-18  |  6.8 KB  |  241 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CTable.h
  3.  
  4.         Interface for Table class
  5.         
  6.     SUPERCLASS = CPanorama
  7.     
  8.     Copyright © 1991 Symantec Corporation. All rights reserved.
  9.     
  10.  
  11.  ******************************************************************************/
  12.  
  13. #define _H_CTable        /* include file only once */
  14.  
  15. #include "CPanorama.h"    /* include superclass interface */
  16.  
  17. #ifndef __LISTS__        /* avoid redeclaration of Cell type, defined in "ListMgr.h" */
  18. typedef Point Cell;
  19. #endif
  20.  
  21. typedef enum tTblDrawOrder /* CTable can draw in row major or column major order */
  22. {    
  23.     tblRow,
  24.     tblCol
  25. } tTblDrawOrder;
  26.  
  27. typedef struct tTableBorder
  28. {
  29.     short     thickness;
  30.     short     penMode;
  31.     Pattern pat;
  32.     
  33. }    tTableBorder;
  34.  
  35. /* selection flags */
  36.  
  37. #define selOnlyOne        1L        /* only one cell can be selected at a time    */
  38. #define    selNoDisjoint    2L        /* no disjoint selections allowed            */
  39. #define selExtendDrag    4L        /* extend selections by selecting hit cells    */
  40.                                 /* not by extending rectangles                */
  41. #define selDragRects    8L        /* dragging always selects rectangles        */
  42.  
  43. class CScrollPane;
  44. class CRunArray;
  45. class CMouseTask;
  46.  
  47. class CTable : public CPanorama
  48. {
  49. public:
  50.  
  51.     void    ITable(CView *anEnclosure, CBureaucrat *aSupervisor,
  52.                 short aWidth, short aHeight,
  53.                 short aHEncl, short aVEncl,
  54.                 SizingOption aHSizing, SizingOption aVSizing);
  55.                 
  56.     virtual void    IViewTemp(CView *anEnclosure, CBureaucrat *aSupervisor,
  57.                             Ptr viewData);
  58.  
  59.     virtual void    SetDefaults( short colWidth, short rowHeight);
  60.     virtual void    SetDrawOrder( tTblDrawOrder aDrawOrder);
  61.     virtual void    SetScrollPane( CScrollPane *aScrollPane);
  62.  
  63.     /* change size */
  64.         
  65.     virtual void    AddRow( short numRows, short afterRow);
  66.     virtual void    AddCol( short numCols, short afterCols);
  67.  
  68.     virtual void    DeleteRow( short numRows, short startRow);
  69.     virtual void    DeleteCol( short numCols, short startCol);
  70.     
  71.     virtual void    SetRowHeight( short rowNum, short newHeight);
  72.     virtual void    SetColWidth( short colNum, short newWidth);
  73.  
  74.     /* query */
  75.     
  76.     virtual void    GetTableBounds( Rect *aTableBounds);
  77.     virtual short    GetRowCount( void);
  78.     virtual short    GetColCount( void);
  79.     virtual short    GetRowHeight( short rowNum);
  80.     virtual short    GetColWidth( short colNum);
  81.     virtual long    GetRowStart( short rowNum);
  82.     virtual long     GetColStart( short colNum);
  83.     
  84.     virtual RgnHandle GetSelection( void);
  85.     virtual long    GetSelectionFlags( void);
  86.         
  87.     virtual void    GetCellRect( Cell theCell, LongRect *cellRect);
  88.     virtual Boolean IsSelected( Cell aCell);
  89.     virtual Boolean NextCell( Boolean hNext, Boolean vNext, Cell *theCell);
  90.     virtual Boolean GetSelect( Boolean next, Cell *theCell);
  91.     
  92.     virtual short    FindRow( long vLoc);
  93.     virtual short    FindCol( long hLoc);
  94.     virtual Boolean PixelsToCells( LongRect *pixelsRect, Rect *cellsRect);
  95.     virtual Boolean CellsToPixels( Rect *cellsRect, LongRect *pixelsRect);
  96.     
  97.     /* clicks */
  98.  
  99.     virtual void    DoClick( Point hitPt, short modifierKeys, long when);
  100.     virtual void    DoDblClick( Cell hitCell, short modifierKeys, long when);
  101.  
  102.     virtual Boolean HitSamePart(Point pointA, Point pointB);
  103.     virtual void    FindHitCell( LongPt *hitPt, Cell *hitCell);
  104.  
  105.     virtual void    SetDblClickCmd( long aCmd);
  106.  
  107.     virtual void    Draw( Rect *area);
  108.  
  109.     virtual void    RefreshCell( Cell aCell);
  110.     virtual void    RefreshCellRect( Rect *cells);
  111.     
  112.     virtual void    SetDrawActiveBorder( Boolean fDrawActiveBorder);
  113.     virtual void    SetRowBorders( short thickness, short penMode, Pattern penPat);
  114.     virtual void    SetColBorders( short thickness, short penMode, Pattern penPat);
  115.     
  116.     virtual void    Paginate( CPrinter *aPrinter, short pageWidth, short pageHeight);
  117.     
  118.     virtual void    Activate( void);
  119.     virtual void    Deactivate( void);
  120.  
  121.     /* typing */
  122.     
  123.     virtual void    DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent);
  124.     virtual void    DoAutoKey(char theChar, Byte keyCode, EventRecord *macEvent);
  125.     
  126.     /* commands */
  127.     
  128.     virtual void    DoCommand( long aCmd);
  129.     virtual void    UpdateMenus( void);
  130.     
  131.     virtual Boolean    BecomeGopher( Boolean fBecoming);
  132.  
  133.     /* selecting */
  134.     
  135.     virtual void    SetSelectionFlags( long selFlags);
  136.     virtual void    SelectCell( Cell aCell, Boolean keepPrevious, Boolean reDraw);
  137.     virtual void    SelectRect( Rect *selectRect, Boolean keepPrevious, Boolean reDraw);
  138.     virtual void    DeselectCell( Cell aCell, Boolean redraw);
  139.     virtual void    DeselectRect( Rect *deselectRect, Boolean redraw);
  140.     virtual void    DeselectAll( Boolean redraw);
  141.     
  142.     virtual void    ScrollToSelection( void);
  143.     
  144.     /* disposal */
  145.     
  146.     virtual void    Dispose( void);
  147.  
  148. protected:
  149.     
  150.     Rect            tableBounds;                /* defines table size in cells            */
  151.     Point            topLeftIndent;                /* top and left indent of entire table    */
  152.     RgnHandle        itsSelection;                /* maintains the selection                */
  153.         
  154.     CRunArray    *itsRows;                        /* runs of row heights                    */
  155.     CRunArray    *itsCols;                        /* runs of column widths                */
  156.  
  157.     tTblDrawOrder    drawOrder;                    /* defines CTable draws in row or column order */
  158.     short            defRowHeight, defColWidth;    /* default size of new rows and cols     */
  159.     long            selectionFlags;                /* flags for selection behavior            */
  160.     
  161.     FontInfo        fontInfo;                    /* for text tables                        */
  162.     Point            indent;                        /* used by subclasses for cell drawing    */
  163.     
  164.     long            dblClickCmd;                /* command sent for cell double click    */
  165.     Boolean            drawActiveBorder;
  166.     Boolean            clipToCells;
  167.     Rect            qdClip;
  168.         
  169.     tTableBorder    rowBorders;
  170.     tTableBorder    colBorders;
  171.     
  172.     static RgnHandle cDeselection, cNewSelection, cCurrHilite;
  173.     
  174.             
  175.     void    ITableX( void);
  176.     virtual void    CreateTextEnvironment( void);
  177.                     
  178.     virtual void    AdjustBounds( void);
  179.  
  180.     virtual CMouseTask *MakeMouseTask( short modifiers);
  181.     virtual void    ClickOutsideBounds( Point hitPt, short modifierKeys, long when);
  182.     
  183.  
  184.     /* drawing */
  185.     
  186.     virtual void    DrawRow( short rowNum, short firstCol, 
  187.                     short lastCol, Boolean doHilite);
  188.     virtual void    DrawCol( short colNum, short firstRow,
  189.                     short lastRow, Boolean doHilite);
  190.     virtual void    DrawCell( Cell theCell, Rect *cellRect);
  191.     
  192.     virtual void    DrawBorders( Rect *theCells);
  193.     virtual void    Hilite( Rect *cells, Boolean hiliteFlag);
  194.     virtual void    HiliteCellRegion( RgnHandle cellRgn, Boolean fHilite);
  195.     
  196.     /* text tables only */
  197.     
  198.     virtual void    GetCellText( Cell aCell, short availableWidth, StringPtr itsText);
  199. };
  200.     
  201. enum    // synonyms for some Boolean parameters
  202. {
  203.     kDontKeepPrevious = FALSE,
  204.     kKeepPrevious,
  205.     kCurrentOnly = FALSE,
  206.     kCurrentOrNext
  207. };
  208.         /* utility macro to set a cell */
  209.             
  210. #define SetCell( aCell, h1, v1)    \
  211.     aCell.h = h1, aCell.v = v1
  212.     
  213.     
  214. /* Change protocol for CTable        */
  215.  
  216. enum
  217. {
  218.     tableSelectionChanged = bureaucratLastChange + 1,    /* info parameter is NULL    */
  219.     
  220.     tableLastChange = tableSelectionChanged
  221.     
  222. };
  223.  
  224. typedef struct
  225. {
  226.     PanoramaTemp    panorama;    /* TCL 1.1.1 DLP 9/18/91 */
  227.     short            numRows;
  228.     short            rowHeight;
  229.     short            numCols;
  230.     short            colWidth;
  231.     long            selectionFlags;
  232.     long            dblClickCmd;
  233.     short            drawActiveBorder;
  234.     short            rowBorderThickness;
  235.     short            rowBorderPenMode;
  236.     short            rowBorderPatID;
  237.     short            colBorderThickness;
  238.     short            colBorderPenMode;
  239.     short            colBorderPatID;
  240.     
  241. } tTableTemp, *tTableTempP;